<template>
  <div class="count">
    <div class="count_count" style="padding-bottom: 4px" >
      <div style="white-space: pre-wrap; " v-for="(item,key) in count" :key="index">
       {{item}}
<!--        <van-highlight :source-string="'请认准蛇货协议球推介平台智博体育，已验证靠谱稳定秒出款 单场投注请勿超过5W 反常注单会引起平台注意 点击下方链接进入 智博体育1919，\\n官方投注入口>>'" />-->
<!--        <p style="white-space: pre-wrap; "> 请认准蛇货协议球推介平台智博体育，已验证靠谱稳定秒出款 单场投注请勿超过5W 反常注单会引起平台注意 点击下方链接进入 智博体育1919，\n官方投注入口>></p>-->

       </div>
<!--      <div>请认准蛇货协议球推介平台</div>-->
<!--      <div>智博体育，已验证靠谱稳定秒出款</div>-->
<!--      <div>单场投注请勿超过5W</div>-->
<!--      <div>反常注单会引起平台注意</div>-->
<!--      <div>点击下方链接进入</div>-->
<!--      <div>智博体育1919，官方投注入口>></div>-->
    </div>
<!--    <div style="margin-bottom: 9px;height: 70px;padding-left: 10px;padding-right: 10px;" @click="openUrl1">-->
<!--      <n-carousel>-->
<!--        <van-image-->
<!--            width="100%"-->
<!--            height="70px"-->
<!--            fit="contain"-->
<!--            :src="banner1"-->
<!--        >-->
<!--          <template v-slot:loading>-->
<!--            <div style="color: #fff;width: 100px">加载中...</div>-->
<!--            &lt;!&ndash;            <van-loading type="spinner" size="20" />&ndash;&gt;-->
<!--          </template>-->
<!--        </van-image>-->
<!--      </n-carousel>-->
<!--    </div>-->
    <div style="display: flex;justify-content: space-between;padding-left: 10px;padding-right: 10px;height: 70px;margin-top: 3px">
      <div style="width:49.5%" @click="toChatRoom">
        <van-image
            width="100%"
            height="70px"
            fit="contain"
            :src="imgfeR"
        >
          <template v-slot:loading>
            <div style="color: #fff;width: 100px">加载中...</div>
<!--            <van-loading type="spinner" size="20" />-->
          </template>
        </van-image>
      </div>
      <div style="width: 1%;height: 2px"></div>
      <div style="width: 49.5%" @click="toVipChat">
        <van-image
            v-if="banner"

            width="100%"
            height="70px"
            fit="contain"
            :src="banner"
        >
          <template v-slot:loading>
            <div style="color: #fff">加载中...</div>
            <!--            <van-loading type="spinner" size="20" />-->
          </template>
        </van-image>
      </div>
    </div>
    <div>

      <div class="login-box_li" style="margin-top: 10px">
        <svg-icon style="width: 1.1rem;height:1.1rem;" name="dianZan" />
        <div style="margin-left: 4px">当前推介</div>
      </div>
      <div style="padding: 8px;" v-if="no_finish.length===0">
        <div style=" background-color: #373737;border-radius: 4px;color: #fff;padding: 8px;font-size: 16px;">
          <div style="line-height: 28px;height: 28px">当前比赛博主还未推单</div>
          <div style="line-height: 28px;height: 28px">预计24小时内推单</div>
          <div style="line-height: 28px;height: 28px">请稍后再来</div>
        </div>
      </div>

      <div class="login-box_list">
        <countList v-for="(item,index) in no_finish" :key="index" :list="item" :count="false"></countList>
      </div>
      <div class="login-box_li" style="margin-top: 6px">
        <svg-icon style="width: 1.1rem;height:1.1rem;margin-top: 0" name="medal"  />
        <div style="margin-left: 4px">历史胜率{{right_rate}}</div>
      </div>
<!--      <div class="login-box_but_list">-->
<!--        <div>历史战绩</div>-->
<!--        <div>月胜率98%</div>-->
<!--      </div>-->
      <div class="login-box_list">
        <countList v-for="(item,index) in finish" :key="index" :list="item" :count="true"></countList>
      </div>



    </div>
  </div>
</template>

<script setup lang="ts">
import {UserRecommendList, ShowNotice,UserWallet} from "@/api/mock";
import { ComponentInternalInstance, getCurrentInstance, onMounted,onBeforeUnmount  } from 'vue';
// import countList from './../../components/count_list/index'
import {ref} from "vue";
import {showFailToast} from "vant";
import {useRouter} from "vue-router";
import imgfeL from '@/image/imager3_0/vipLts.png'
import imgfeR from '@/image/imager3_0/qmLts.png'

// src/image/imager3_0/qmLts.png
// src/image/imager3_0/vipLts.png

const { proxy } =  getCurrentInstance() as ComponentInternalInstance
const router = useRouter()
const right_rate = ref('')
const toVipChat = ()=>{
  router.push({
    path: "/vipChat",
    query: {
      mode: "",
    },
  });
}
const userWallet = ()=>{

  let pa = {
    user_id:localStorage.getItem("token")
  }
  if(!pa.user_id){
    proxy.$sayIs_vip(1)
    userRecommendList()

    // return
  }else{
    UserWallet(pa).then(
        (res) => {
          if (+res.code === 200){
            proxy.$sayIs_vip(res.data.is_vip)
            userRecommendList()

            // toLogin()
          }else{
            showFailToast(res.msg);

          }

        },
        err => {
          console.log(err);
          // showFailToast("请求有误");
        }
    );
  }
  console.log(pa)

}

const count = ref([])
const finish = ref([])
const no_finish = ref([])
const link = ref('')
onMounted(() => {
  showNotice()
  userWallet()
})
const userRecommendList = async () => {
  let pa = {
    is_vip:proxy.$is_vip
    // is_vip:2
  }
  const res = await UserRecommendList(pa)
  if (+res.code === 200) {
    finish.value = res.data.finish
    no_finish.value = res.data.no_finish
    right_rate.value =  res.data.right_rate
    // count.value = res.data.content
    // link.value =  res.data.link
  }
}
const  openUrl = ()=>{
  window.location=link.value
}
const  openUrl1 = ()=>{
  window.location=link1.value
}


const banner = ref('')
const link1 = ref('')
const banner1 = ref('')
const showNotice = async () => {
  const res = await ShowNotice();
  if (+res.code === 200) {
    count.value = res.data[0].content.split('\n');
    link.value =  res.data[0].link
    banner.value = res.data[0].banner
    banner1.value = res.data[2].banner
    link1.value = res.data[2].link
  }
  // console.log(res)
}


// const showNotice = async () => {
//   await ShowNotice().then(res => {
//     debugger
//     if (+res.code === 200) {
//       count.value = res.data.content
//       console.log(res)
//     }
//   }, err => {
//     console.log(err);
//     showFailToast("请求有误");
//   })
// }
const toChatRoom = ()=>{
  router.push({
    path: "/chatRoom",
    query: {
      mode: "",
    },
  });
}
const toVipChatRoom = ()=>{
  router.push({
    path: "/vipChat",
    query: {
      mode: "",
    },
  });
}
const list = ref<object>({li:11})
// const

</script>

<style scoped lang="less">
.count{
  background-color: #282828;
  .login-box_but_list{
    padding: 0 10px;
    display: flex;
    justify-content: space-between;
    div{
      width: 100%;
      text-align: center;
      color: #fff;
    }
  }
  .count_count{
    margin-top: 10px;
    >div{
      padding: 0 12px;
      //padding: 0 40px;
      color: #fff;
      text-align: left;
      font-size: 14px;
      line-height: 26px;
      font-weight: bold;
    }
  }
  .login-box_li{
    padding-left: 12px;
    //background-color: #282828;
    color: #7FDCAB;
    display: flex;
    justify-content: left;
    align-items: center;
    margin: 16px 0 0 0;
    font-weight: bold;
    font-size: 1rem;
  }
  .login-box_list{
    padding: 0px 8px 8px 8px;
  }

}
::v-deep .van-image__img{
  max-height: 70px;
}
::v-deep .van-image__loading{
  background-color: rgb(40, 40, 40) !important;
}

</style>
